package edu.pku.sei.autounit.generator;

import edu.pku.sei.autounit.core.DefaultVariable;
import edu.pku.sei.autounit.core.Variable;
import edu.pku.sei.autounit.core.VariableFactory;
import edu.pku.sei.autounit.core.VariableGenerator;
import edu.pku.sei.autounit.filter.Filter;
import edu.pku.sei.autounit.reflect.Context;
import edu.pku.sei.autounit.reflect.Type;
import edu.pku.sei.autounit.reflect.java.TypeFactory;
import edu.pku.sei.autounit.util.NameFactory;
import edu.pku.sei.autounit.util.Statements;

public class SpecialTypeGenerator implements VariableGenerator{

	
	public Variable generate(Type type, String name, VariableFactory vf,
			NameFactory nf) {
		if(type instanceof Context){
			TypeFactory tf = new TypeFactory();
			Type t = tf.getType(System.in.getClass(), null);
			if(type.isAssignableFrom(t))
				return new DefaultVariable(type, new Statements(), "System.in");
			t = tf.getType(System.out.getClass(), null);
			if(type.isAssignableFrom(t))
				return new DefaultVariable(type, new Statements(), "System.out");
			t = tf.getType(java.lang.Class.class, null);
			if(type.isAssignableFrom(t))
				return new DefaultVariable(type, new Statements(), "String.class");
		}
		return null;
	}

	
	public Variable generate(Type type, String name, Filter fliter,
			VariableFactory vf, NameFactory nf) {
		return null;
	}
}
